package health_system.health_system.entity;

import jakarta.persistence.*;
import jakarta.validation.constraints.Size;
import lombok.Getter;
import lombok.Setter;

import java.time.LocalDateTime;

@Getter
@Setter
@Entity
@Table(name = "friendships", uniqueConstraints = {
    @UniqueConstraint(columnNames = {"requester_id", "addressee_id"})
})
public class Friendship extends BaseEntity {

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "requester_id", nullable = false)
    private User requester;
    
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "addressee_id", nullable = false)
    private User addressee;
    
    @Enumerated(EnumType.STRING)
    @Column(nullable = false)
    private FriendshipStatus status = FriendshipStatus.PENDING;
    
    private LocalDateTime acceptedAt;
    
    @Size(max = 100)
    private String requesterNote;
    
    @Size(max = 100)
    private String addresseeNote;
    
    @Size(max = 100)
    private String friendCircle;
    
    @OneToOne(mappedBy = "friendship", cascade = CascadeType.ALL, fetch = FetchType.LAZY, orphanRemoval = true)
    private PrivacySettings privacySettings;
    
    public enum FriendshipStatus {
        PENDING, ACCEPTED, REJECTED, BLOCKED
    }
} 